package com.wg.elasticsearch.service;


import com.wg.elasticsearch.model.ShowContent;
import com.wg.elasticsearch.param.ContentParam;
import com.wg.elasticsearch.result.ResultSupport;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestResult;

import java.util.List;

/**
 * Created by mc on 18/6/22.
 * es服务类
 */
public interface ElasticsearchService {

    /**
     * 创建索引
     * @param indexName
     * @return
     */
    public boolean createIndex(String indexName);


    /**
     * Delete索引
     * @param indexName
     * @return
     * @throws Exception
     */
    public boolean delete(String indexName);


    /**
     * 创建映射推送数据
     * @param indexName
     * @param typeName
     * @param source
     * @param list<Object>
     * @return
     * @throws Exception
     */
    public boolean createMappingPushData( String indexName, String typeName, String source, List<Object> list);


    /**
     * Put映射
     * @param indexName
     * @param typeName
     * @param source
     * @return
     * @throws Exception
     */
    public boolean createIndexMapping(String indexName, String typeName, String source) ;

    /**
     * 索引文档
     * @param indexName
     * @param typeName
     * @param objs
     * @return
     * @throws Exception
     */
    public boolean insert(String indexName, String typeName, List<Object> objs);

    /**
     * 获取字段
     * @return
     */
    public String getSourceName();

    /**
     * 获取es最大更新时间
     * @return
     */
    public String getMaxUpdateTime();

    /**
     * 更新es文档
     * @param indexName
     * @param typeName
     * @param objs
     * @return
     */
    public boolean update(String indexName, String typeName, List<ShowContent> objs);

    /**
     * Get文档
     * @param indexName
     * @param typeName
     * @param id
     * @return
     * @throws Exception
     */
    public ShowContent get(String indexName, String typeName, String id);


    public ResultSupport<List<ShowContent>> search(ContentParam param);

}
